Source Code Viewer - Example 3 - ViewCountryAction

package name.matthewgreet.example3.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.opensymphony.xwork2.ActionSupport;

import name.matthewgreet.example3.common.AbstractViewActionSupport;
import name.matthewgreet.example3.common.BrowserTabSession;
import name.matthewgreet.example3.common.ListCache;
import name.matthewgreet.example3.form.CountryForm;
import name.matthewgreet.example3.view.CountryDetailDisplay;
import name.matthewgreet.example3.vo.CountryDTO;


/**
 * Displays country from in-memory table. 
 */
@InterceptorRef("ViewStack")
@Results({
	@Result(name=ActionSupport.SUCCESS, location="/pages/Country.jsp")
})
public class ViewCountryAction extends AbstractViewActionSupport {
	private static final long serialVersionUID = -7979376337555804889L;
	
	private Integer index;
	
	private CountryForm form;
	
	private CountryDetailDisplay display;
	
	
    @Action("/ViewCountry")
    @Override
    public String execute() throws Exception {
    	BrowserTabSession session;
    	ListCache<Integer,CountryDTO> listCache;
    	
    	session = getBrowserTabSession();
    	listCache = ViewCountryListAction.retrieveListCache(session);
    	if (index != null) {
    		listCache.setSelectedIndex(index);
    	}
    	if (form == null) {
    		form = new CountryForm(listCache.getSelected());
    	}
    	display = new CountryDetailDisplay(listCache);
    	display.init();
		return SUCCESS;
    }

	public Integer getIndex() {
		return index;
	}
	public void setIndex(Integer index) {
		this.index = index;
	}

	public CountryForm getForm() {
		return form;
	}

	public CountryDetailDisplay getDisplay() {
		return display;
	}

}